<?php

$api = app('Dingo\Api\Routing\Router');
$moduleName = 'Asset';

// 平台后台api
$api->version('v1', ['prefix' => 'admin-api', 'namespace' => 'Modules\\'.$moduleName.'\Http\Controllers\Admin\V1'], function ($api) {
	$allMethod = ['index', 'show', 'store', 'update', 'destroy'] ;

	$api->get('assets/{assetType}/withdraw', ['uses'=> "WithdrawRecordController@index"]);
	$api->patch('assets/{assetType}/withdraw/{uuid}', ['uses'=> "WithdrawRecordController@update"]);
	$api->delete('/assets/redpack/withdraw/{uuid}', ['uses'=> "WithdrawRecordController@destroy"]);
	$api->get('/status-total/withdraw-record', ['uses'=> "WithdrawRecordController@statusTotal"]);

	$api->get('asset-records/{assetType}', ['uses'=> "AssetRecordController@index"]);
	$api->get('assets/{assetType}', ['uses'=> "AssetController@show"]);

	// $api->get('asset/package-skus', ['uses'=> "PackageSkuController@index"]);

	$api->resource('asset/score-skus', "ScoreSkuController", ['only' => $allMethod]);
	$api->resource('asset/redpack-skus', "RedpackSkuController", ['only' => $allMethod]);
	$api->resource('asset/package-skus', "PackageSkuController", ['only' => $allMethod]);

	$api->get('/status-total/package-sku', ['uses'=> "PackageSkuController@statusTotal"]);

	$api->resource('bank-cards', "BankCardController", ['only' => $allMethod]);

	$api->post('/export/withdraw', ['uses'=> "WithdrawExportController@store"]);
	$api->post('/export/withdraw/total', ['uses'=> "WithdrawExportController@total"]);
	$api->get('/export/withdraw/{uuid}', ['uses'=> "WithdrawExportController@show"]);

	$api->post('/export/package-sku', ['uses'=> "PackageSkuExportController@store"]);
	$api->post('/export/package-sku/total', ['uses'=> "PackageSkuExportController@total"]);
	$api->get('/export/package-sku/{uuid}', ['uses'=> "PackageSkuExportController@show"]);

	$api->get('/asset/resales', ['uses'=> "ResaleController@index"]);
	$api->delete('/asset/resales/{uuid}', ['uses'=> "ResaleController@destroy"]);
	$api->get('/status-total/resale', ['uses'=> "ResaleController@statusTotal"]);

	$api->post('/export/redpack-record', ['uses'=> "RedpackRecordExportController@store"]);
	$api->post('/export/redpack-record/total', ['uses'=> "RedpackRecordExportController@total"]);
	$api->get('/export/redpack-record/{uuid}', ['uses'=> "RedpackRecordExportController@show"]);
});

// 租户api
// $api->version('v1', ['prefix' => 'tenant-api', 'namespace' => 'Modules\\'.$moduleName.'\Http\Controllers\Tenant\V1'], function ($api) {
// 	$allMethod = ['index', 'show', 'store', 'update', 'destroy'];
// });

// 普通用户api
$api->version('v1', ['namespace' => 'Modules\\'.$moduleName.'\Http\Controllers\Client\V1'], function ($api) {
	$allMethod = ['index', 'show', 'store', 'update', 'destroy'];

	$api->get('asset-records/{assetType}', ['uses'=> "AssetRecordController@index"]);
	$api->get('assets/{assetType}', ['uses'=> "AssetController@show"]);

	// 余额提现
	$api->post('balance/withdraw', ['uses'=> "WithdrawController@store"]);
	$api->get('balance/withdraw/list', ['uses'=> "WithdrawController@index"]);
	// 提现情况(可提现金额、可用提现方式等)
	$api->get('balance/withdraw/detail', ['uses'=> "WithdrawController@detail"]);

	// 我的仓库开盒次数
	$api->get('asset/packages', ['uses'=> "PackageController@index"]);
	// 我的仓库物品
	$api->get('asset/package-skus', ['uses'=> "PackageSkuController@index"]);
	// 奖品详情
	$api->get('asset/package-skus/{uuid}', ['uses'=> "PackageSkuController@show"]);
	// 奖品提取详情
	$api->get('asset/pick-order/preview', ['uses'=> "PickOrderController@preview"]);

	// 试一试的结果
	$api->get('try/packages/{uuid}', ['uses'=> "PackageController@showTry"]);
	// 查看一个订单开出的物品
	$api->get('asset/package', ['uses'=> "PackageController@show"]);
	// 按订单id开启一个盲盒
	$api->post('asset/package/open', ['uses'=> "PackageController@open"]);

	// 积分套餐列表
	$api->get('asset/score-skus', ['uses'=> "ScoreSkuController@index"]);
	$api->post('asset/score-order/confirm', ['uses'=> "ScoreOrderController@confirm"]);

	// 余额套餐列表
	$api->get('asset/redpack-skus', ['uses'=> "RedpackSkuController@index"]);
	$api->post('asset/redpack-order/confirm', ['uses'=> "RedpackOrderController@confirm"]);

	// 预览返售
	$api->post('asset/return-sale/preview', ['uses'=> "ReturnSaleController@preview"]);
	// 确认提交返售
	$api->post('asset/return-sale/confirm', ['uses'=> "ReturnSaleController@confirm"]);

	// 预览发货订单
	$api->post('package/deliver-order/preview', ['uses'=> "DeliverOrderController@preview"]);
	// 提交发货订单
	$api->post('package/deliver-order/confirm', ['uses'=> "DeliverOrderController@confirm"]);

	// 预览提货订单
	$api->post('package/pick-order/preview', ['uses'=> "PickOrderController@preview"]);
	// 提交提货订单
	$api->post('package/pick-order/confirm', ['uses'=> "PickOrderController@confirm"]);
	// 领取虚拟奖品
	$api->post('package-skus/{uuid}/virtual-asset/pick', ['uses'=> "PackageSkuController@pickVirtualAsset"]);
	// 锁定物品
	$api->post('package-skus/{uuid}/lock', ['uses'=> "PackageSkuController@lock"]);
	// 解锁物品
	$api->post('package-skus/{uuid}/unlock', ['uses'=> "PackageSkuController@unlock"]);

	// 创建一个转售
	$api->post('asset/resales', ['uses'=> "ResaleController@store"]);
	// 转售详情
	$api->get('asset/resales/{uuid}', ['uses'=> "ResaleController@show"]);
	// 转售大厅
	$api->get('asset/resales', ['uses'=> "ResaleController@index"]);

	$api->post('asset/resale/preview', ['uses'=> "ResaleController@preview"]);
	// 购买转售
	$api->post('asset/resale-order/confirm', ['uses'=> "ResaleOrderController@confirm"]);
	// 取消转售
	$api->put('asset/resales/{uuid}', ['uses'=> "ResaleController@update"]);

	$api->get('/status-total/package-sku', ['uses'=> "PackageSkuController@statusTotal"]);

	// 银行卡管理 
	$api->resource('bank-cards', "BankCardController", ['only' => $allMethod]);
});